var express = require('express');
var router = express.Router();

/* GET articles listing. */
router.get('/', function(req, res, next) {
  res.send('respond with a resource');
});
router.get('/post', function(req, res, next) {
  res.render('articles',{});
});
router.post('/post',function(req,res,next){
	if(!req.articals)
	return next(new Error('article is not exists'));
	 console.log(req.body.title);
	console.log(req.body.content);
	req.articals.insertOne({title:req.body.title,content:req.body.content});
    res.redirect('..');
});
module.exports = router;
